package eu.ahsx.limboa.utils
{
	
	/***
	 * 	ArrayUtils
	 * 	Bunch of class usefull for handling arrays
	 * 	
	 * 	@author Masy Alexandre
	 * */
	public class ArrayUtils
	{
		/**
		 * 	Merge the given arrays
		 * 	If the destination array is not given, then a new one is returned
		 * 
		 * 	@param dest Array
		 * 	@param ...arr Array List of array you want merge
		 * 	@return Array
		 * 	@langversion ActionScript 3.0
		 * 	@playerversion Flash 9
		 * */
		public static function merge(dest:Array = null, ...arr):Array
		{
			var ret:Array = [];
			if (dest)
				ret = dest;
			
			var n:int = arr.length;
			var m:int = 0;
			var a:Array;
			while(--n>=0)
			{
				a = arr[n];
				m = a.length;
				while(--m>=0)
				{
					ret.push(a[m]);
				}
			}
			
			return ret;
		}
	}
}